home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 2.7 KB | 97 lines | [TEXT/KAHL] |
- /***********************************************************************************
- CColumnizer.cp
-
- Copyright © 1994 B-Ray Software. All rights reserved.
- Developed using Symantec C++ 7.0 and Symantec's TCL library.
- Portions of this code courtesy Symantec, Inc.
-
- This code may be freely distributed as long as this notice remains. The code
- may not be used in any commercial software without the consent of B-Ray Software.
-
- ---
-
- The Columnizer class provides vertical position management for child panes
- of a particular parent. This class simply defines 3 functions that are
- pure virtual in the RowColumnMgr class. These functions work with with vertical
- values, compared to the Rowizer class which works with horizontal values --
- that is the only difference between the two.
-
- ***********************************************************************************/
-
- #include "CColumnizer.h"
-
-
- TCL_DEFINE_CLASS_M1( CColumnizer, CRowColumnMgr );
-
-
- /*
- * PositionChild
- *
- * Adjust a child's position so that it is situated properly among its siblings.
- */
-
- void CColumnizer :: PositionChild( CPane *aChild, long index )
- {
- long numItems = GetNumberChildren();
-
- aChild->Prepare();
-
- if ( index < 2 ) { // become first child in list
- aChild->Place( aChild->hEncl, 0, FALSE );
- }
- else if ( index > numItems ) { // become last child in list
- CPane *lastPane = GetChildAtIndex( numItems )->ChildToPane();
- aChild->Place( aChild->hEncl, lastPane->vEncl + lastPane->height, FALSE );
- }
- else { // somewhere in between...
- CPane *beforePane = GetChildAtIndex( index )->ChildToPane();
- aChild->Place( aChild->hEncl, beforePane->vEncl, FALSE );
- }
- }
-
-
- /*
- * AdjustDelta
- *
- * Zaps out unused portions of the given Rect parameter. RowColumnMgr calls this
- * function but does not define one, so we must. Zero out all values but the
- * vertical size amount (delta->bottom).
- */
-
- void CColumnizer :: AdjustDelta( Rect *delta )
- {
- delta->left = delta->top = delta->right = 0;
- }
-
-
- /*
- * GetFamilySize
- *
- * Calculates and returns the dimensions of the smallest rectangle to enclose all
- * of the children.
- */
-
- static void FindChildSize( CFamily *aChild, long param )
- {
- CPane *aPane;
- Point *aPt = (Point *)param;
- short aWidth, aHeight;
-
- aPane = aChild->ChildToPane(); // get CPane part of object
- aPane->GetLengths( &aWidth, &aHeight ); // get its dimensions
- aWidth += aPane->hEncl; // take into account any offset
- if ( aWidth > aPt->h ) aPt->h = aWidth;
- aPt->v += aHeight; // increase the parent's height
- }
-
- void CColumnizer :: GetFamilySize( short *aWidth, short *aHeight )
- {
- Point aPt = { 0, 0 };
-
- if ( itsChildren )
- itsChildren->DoForEach1( FindChildSize, (long )&aPt );
-
- *aWidth = aPt.h;
- *aHeight = aPt.v;
- }
-